﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using BawangMemo.BawangMemoView.View;
using BawangMemo.BackendModels;

namespace BawangMemo.BawangMemoView
{
    public class MainWindowManager
    {

        public static MainWindow _mainWindow;
        public CourseWrapper _courseWrapper;

        #region Constructor

        public MainWindowManager(MainWindow mainWindow, CourseWrapper courseWrapper)
        {
            _mainWindow = mainWindow;
            _courseWrapper = courseWrapper;
        }

        #endregion

        #region View Manage

        public void StartView(string view)
        {
            if (view.Equals("settingButton"))
            {
                Bawang_Setting setting = new Bawang_Setting();
                setting.ShowDialog();
                return;
            }

            _mainWindow.grid1.Children.Clear();

            if (view.Equals("memoButton"))
            {
                MemView memView = new MemView(_courseWrapper);
                if (!memView.IsFinish)
                    _mainWindow.grid1.Children.Add(memView);
            }
            else if (view.Equals("bankButton"))
                _mainWindow.grid1.Children.Add(new BankView(_courseWrapper));
            //            else if (view.Equals("
            else if (view.Equals("testButton"))
            //_mainWindow.grid1.Children.Add(new TestView(_courseWrapper));
            {
                //TestView tv = new TestView(_courseWrapper);
                //tv.Show();

                Test_SetupDia tsd = new Test_SetupDia(_courseWrapper);
                tsd.ShowDialog();
                if (tsd.winner == true)
                {
                    _mainWindow.grid1.Children.Add(new TestView(_courseWrapper, _mainWindow, tsd));
                }
            }
            else if (view.Equals("gameButton"))
            {
                //
                _mainWindow.grid1.Children.Add(new ListSelectView(_courseWrapper, this));
            }
            else if (view.Equals("backButton"))
            {
                new IntroWindow().Show();
                App.IsShuttingDown = false;
                _mainWindow.Close();
                App.IsShuttingDown = true;
            }
            else if (view.Equals("quitButton"))
            {
                _mainWindow.Close();
                App.Current.Shutdown();
            }
            else if (view.Equals("statisticButton"))
            {
                _mainWindow.grid1.Children.Add(new StatView(_courseWrapper));
            }

        }

        public void EndView()
        {

        }

        #endregion
    }
}
